package com.zyh.kaoshi;

import java.util.Scanner;
/*
    键盘输入长度为8的字符串，将所有的大写字符替换为M
 */
public class Test6 {
    public static void main(String[] args) {
        System.out.println("请输入长度为8的字符串：");
        String input = new Scanner(System.in).nextLine();
        if (input.length() == 8) {
            char[] chs = input.toCharArray();
            for (int i = 0; i < chs.length; i++) {
                if (chs[i] >= 'A' && chs[i] <= 'Z') {
                    chs[i] = 'M';
                }
            }
            String s = new String(chs);
            System.out.println("s = " + s);
        } else {
            System.out.println("长度必须为8！");
        }
    }
}
